﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Reflection;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.DiskFileUpload_GUID.Value = System.Guid.NewGuid().ToString();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string uploadId
            = this.Request[DiskFileUpload.UploadFiles.DiskFileUpload_GUID];
        using (DiskFileUpload.UploadFiles list
            = this.Context.Application[uploadId] as DiskFileUpload.UploadFiles)
        {
            if (list != null)
            {
                int i = 0;
                for (; i < list.Count; i++)
                {
                    if (!list[i].IsFormField)
                    {
                        break;
                    }
                }

                this.Label1.Text =
                    string.Format("Path: {0}, Length: {1}, Temp: {2}",
                    list[i].ClientFullPath,
                    list[i].Length,
                    list[i].TempFullPath
                    );

                list[i].SaveAs(
                    this.MapPath(string.Format("~/App_Data/{0}", list[i].FileName))
                    );
            }
        }
    }
}